package com.mlf.singleton;

import com.mlf.singleton.singleton.demo.*;

//测试
public class SingletonDemo {
    public static void main(String[] args) {
        EagerSingleton.getInstance().showMessage();
        LazySingleton.getInstance().showMessage();
        ThreadSafeSingleton.getInstance().showMessage();
        DoubleCheckedSingleton.getInstance().showMessage();
        InnerClassSingleton.getInstance().showMessage();

        //验证是否是同一个实例对象
        System.out.println("same instance? = " +
                (EagerSingleton.getInstance() == EagerSingleton.getInstance()));
    }
}
